﻿<!DOCTYPE html>
<!--[if lt IE 7]>    <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="zh-cn" > <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="zh-cn" > <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="zh-cn" ><![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="zh-cn">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>我的订单</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no" />
    <meta name="”apple-mobile-web-app-capable”" content="”yes”" />

    <!-- 加载js/css -->
    <link type="text/css" rel="stylesheet" href="/shop/templates/yeshou/css/font-awesome.min.css?v=3">
    <link type="text/css" rel="stylesheet" href="/shop/templates/yeshou/css/wapmain.css?v=5">
    <script type="text/javascript" src="/shop/templates/yeshou/js/zepto.min.js?v=3"></script>
    <script>
        var _hmt = _hmt || [];
        var basePath = "{$yuming}", baseParam = "";
        (function () {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?7c10355ee0f6b21af208947325fd4ad7";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
</head>
<body>
    <div id="J_Wrappear">
        <div class="lay-wrap J_MenuBody" id="J_MenuSwipe">
            <!--顶部-->
            <vt:template id="header" file="_header.html" charset="utf-8" />
            <!--end顶部-->

            <script>


                $(document).ready(function () {
                    initCart();
                });

                /**重新加载购物车数量和总价**/
                function initCart() {
                    $.ajax({
                        url: '/shop/shopmgr.ashx?wid={$wid}&openid={$openid}&myact=pcount&ss=' + Math.random(),
                        dataType: 'json',
                        async: false,
                        success: function (data) {
                            if (data.data > 0) {
                                var num = data.data;
                                var cart_a_link = $(".m-shop-cart");
                                if (num != 'undefined' && parseInt(num) > 0) {
                                    if (cart_a_link.find("i.shop-num").length > 0) {
                                        cart_a_link.find("i.shop-num").text(num);
                                    } else {
                                        cart_a_link.prepend($("<i class=\"shop-num\">" + num + "</i>"));
                                    }
                                }
                            }
                        }
                    });
                }

                //立即支付
                function lijizhifu(orderId) {
                    //var rpage = "/shop/userinfo.aspx?&wid={$wid}&openid={$openid}";
                    //var add = "/api/payment/paypage.aspx?showwxpaytitle=1&paytype=shop&wid={$wid}&openid={$openid}&orderid=" + orderId + "&rpage=" + escape(window.basePath + "/shop/userinfo.aspx?&wid={$wid}&openid={$openid}") + "";
                    var add = "/api/payment/paypage.aspx?showwxpaytitle=1&paytype=shop&wid={$wid}&openid={$openid}&orderid=" + orderId;
                    location.href = add;
                }

                //跳转到订单详情
                function toOrderDetailView(orderSn) {
                    window.location.href = "/shop/order_detail.aspx?wid={$wid}&openid={$openid}&orderid=" + orderSn;
                }

                //确认收货
                function shouhuo(orderId) {
                    if (confirm("确认收货吗？")) {
                        $.ajax({
                            type: "GET",
                            url: "/shop/shopmgr.ashx?&myact=shouhuo",
                            data: {
                                order_id: orderId,
                            },
                            dataType: "json",
                            success: function (result) {
                                if (result.errCode == true) {

                                    window.location.href = "/shop/userinfo.aspx?wid={$wid}&openid={$openid}";
                                } else {
                                    alert(result.msg);
                                }
                            }
                        });
                    }
                }
                //取消订单
                function cancelOrder(orderId, orderSn) {
                    if (confirm("确定取消订单【" + orderSn + "】吗？")) {
                        $.ajax({
                            type: "GET",
                            url: "/shop/shopmgr.ashx?&myact=order_canel",
                            data: {
                                order_id: orderId,
                            },
                            dataType: "json",
                            success: function (result) {
                                if (result.errCode == true) {
                                    alert(result.msg);
                                    window.location.href = "/shop/userinfo.aspx?wid={$wid}&openid={$openid}";
                                } else {
                                    alert(result.msg);
                                }
                            }
                        });
                    }
                }

            </script>

            <div class="lay-til J_MenuBody" id="J_SubHead">
                <div class="header-con">
                    <i class="arrow-back" onclick="history.go(-1)">
                        <img src="/shop/templates/yeshou/images/pay_03.png" alt="" /></i>
                    <h1>我的订单</h1>
                </div>
            </div>
            <div class="lay-body" id="J_MainBody">
                <div class="user">
                    <div class="user-group">
                        <!-- <h3>我的订单</h3>-->

                        <!--待付款-->
                        <vt:foreach from="$o_dfu" item="o" index="i">  
                        <div class="bar-group">
                            <p class="name" onclick="toOrderDetailView('{$o.id}')">{$o.order_no}</p>
                            <p class="price">￥ {$o.order_amount}</p> 
                            <p class="last">
                                <a href="javascript:void(0);" onclick="lijizhifu('{$o.id}');" class="link">立即付款</a>
                            </p> 
                            <p class="last" style="width:100%;margin-top:10px;">
                                <a href="javascript:void(0);" onclick="cancelOrder('{$o.id}','{$o.order_no}');" class="link">取消订单</a> 
                            </p> 
                        </div> 
                        </vt:foreach>
                        <!--待收货-->
                        <vt:foreach from="$o_dsh" item="o" index="i"> 
                        <div class="bar-group">
                            <p class="name" onclick="toOrderDetailView('{$o.id}')">{$o.order_no}</p>
                            <p class="price">￥ {$o.order_amount}</p> 
                            <p class="last">
                                <a href="javascript:void(0);" class="link" onclick="shouhuo('{$o.id}');">确认收货</a> 
                            </p> 
                            <p class="last" style="width:100%;margin-top:10px;">
                                <a href="/shop/orderProducts.aspx?wid={$wid}&openid={$openid}&orderid={$o.id}" class="link">查看物流</a> 
                            </p> 
                            <p class="last" style="width:100%;margin-top:10px;">
                                <a href="javascript:void(0);" onclick="cancelOrder('{$o.id}','{$o.order_no}');" class="link">取消订单</a> 
                            </p> 
                             
                        </div> 
                        </vt:foreach>
                        <!--已取消-->
                        <vt:foreach from="$o_yjs" item="o" index="i"> 
                        <div class="bar-group" onclick="toOrderDetailView('{$o.id}')">
                            <p class="name">{$o.order_no}</p>
                            <p class="price">￥ {$o.order_amount}</p> 
                            <p class="last">
                                <button type="button" class="gay">已取消</button>
                            </p> 
                        </div> 
                        </vt:foreach>
                    </div>
                </div>
            </div>
        </div>
        <div class="m-mask J_MenuBody" id="J_Mask"></div>

        <!--左边菜单-->
        <vt:template id="_bottom" file="_bottom.html" charset="utf-8" />
        <!--end左边菜单-->
        <script type="text/javascript" src="/shop/templates/yeshou/js/main.js"></script>
        <script type="text/javascript" src="/shop/templates/yeshou/js/idangerous.swiper.min.js"></script>

    </div>
</body>
</html>
